/*
 * Copyright (c) 2006, 2023, webrx.cn All rights reserved.
 *
 */

package cn.webrx;

import org.jsoup.Jsoup;

import java.io.IOException;
import java.util.Scanner;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

/**
 * <p>Project: jse2303 - PhoneDemo
 * <p>Powered by webrx On 2023-07-18 11:41:24
 * <p>描述：<p>
 *
 * @author webrx [webrx@126.com]
 * @version 1.0
 * @since 17
 */
public class PhoneDemo {
    public static void main(String[] args) throws IOException {
        Scanner sc = new Scanner(System.in);
        System.out.print("请输入手机号：");
        String tel = sc.nextLine();

        String u = String.format("https://ip138.com/mobile.asp?mobile=%s&action=mobile", tel);
        //System.out.println(u);
        String html = Jsoup.connect(u).get().toString();
        //System.out.println(html);

        Pattern pattern = Pattern.compile("<td><span>(.*)</span></td>");
        Matcher matcher = pattern.matcher(html);
        while (matcher.find()) {
            System.out.println(matcher.group(1).replace("&nbsp;", " "));
        }
    }
}
